#include "stdafx.h"

#include "include\\SDL.h"
#pragma comment(lib, "lib\\x86\\SDL2main.lib")
#pragma comment(lib, "lib\\x86\\SDL2.lib")
#pragma comment(lib, "lib\\x86\\SDL2test.lib")

#include "GameDirector.h"

SDL_Window* pWindow = nullptr;
SDL_Renderer* pRenderer = nullptr;

bool is_runing = true;

GameDirector director;

void HandleEvent() {
	SDL_Event e;
	while (SDL_PollEvent(&e)) {
		switch (e.type) {
		case SDL_QUIT:
			is_runing = false;
			break;
		default:
			break;
		}
	}
}

void Draw() {
	SDL_RenderClear(pRenderer);
	// add my draw code here
	// render emmmmmm...
	
	SDL_RenderPresent(pRenderer);
}

int main(int, char**) {
	int result;
	result = SDL_Init(SDL_INIT_EVERYTHING);
	if (result == -1) {
		printf("Fatal Error: SDL_Init Failed\n");
		return 1;
	}
	pWindow = SDL_CreateWindow("Don't Tap The White Tile", 10, 10, 400, 600, SDL_WINDOW_OPENGL);
	pRenderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_SOFTWARE);
	SDL_RenderClear(pRenderer);
	SDL_SetRenderDrawColor(pRenderer, 255, 255, 255, 255);

	SDL_Rect rect = { 0,0,200,200 };
	SDL_RenderFillRect(pRenderer, &rect);
	SDL_RenderPresent(pRenderer);


	Uint32 tbefore = SDL_GetTicks();
	while (is_runing) {
		HandleEvent();
		if ((SDL_GetTicks() - tbefore) > 34) {
			Draw();
			tbefore = SDL_GetTicks();
		}
	}
	SDL_DestroyRenderer(pRenderer);
	SDL_DestroyWindow(pWindow);
	SDL_Quit();
	return 0;
}

